home *** CD-ROM | disk | FTP | other *** search
- 'Programming by Sean J. Miller
- 'Updated November 9, 1994.
- ' -------------------------------------------------------------------------
- DECLARE FUNCTION xRead& LIBRARY
- LONGINT offset&,samples_per_second&
- DECLARE SUB parse_sample(f$)
- DECLARE SUB play_sound(f$)
- DECLARE SUB TotalTime(TIME)
- DECLARE SUB Center(row,Text$)
- DECLARE SUB LineCenter(Text$)
- DECLARE SUB WordWrap(Text$)
- DECLARE SUB Wrong_Sound
- DECLARE SUB Right_Sound
- DECLARE SUB Lookback(most%,b%)
- '--------------------------------------------------------------------------
- CONST MAX=80
- DIM question$(MAX) SIZE 180, answer$(MAX) SIZE 180, gotit%(MAX), RightIFFs$(40) SIZE 90, WrongIFFs$(40) SIZE 90, mode%(9)
- #include <WBarg.h>
- ON WINDOW GOTO ending
- '--------------------------------------------------------------------------
- a$="assign 80Questions: "+CHR$(34)+CHR$(34)
- SYSTEM a$
- OPEN "I",1,"RightIFFs"
- rightsound%=0
- WHILE NOT EOF(1) AND rightsound%<>40
- ++rightsound%
- LINE INPUT #1,RightIFFs$(rightsound%)
- WEND
- CLOSE #1
-
- OPEN "I",1,"WrongIFFs"
- wrongsound%=0
- WHILE NOT EOF(1) AND wrongsound%<>40
- ++wrongsound%
- LINE INPUT #1,WrongIFFs$(wrongsound%)
- WEND
- CLOSE #1
-
- OPEN "I",1,"80Questions.cfg"
- IF EOF(1) = 0 THEN
- INPUT #1,xm%,ym%,wm%,hm%,xg%,yg%,roro%,samps%,srsr%,talk%,dummy
- ELSE
- xm%=0:ym%=0:wm%=444:hm%=166:xg%=0:yg%=0:roro%=0:samps%=0:srsr%=0
- talk%=0
- END IF
- IF samps%=1 AND (wrongsound%=0 OR rightsound%=0) THEN samps%=0
- CLOSE #1
-
- '--------------------------------------------------------------------
- randseed=(TIMER MOD 3)*TIMER:RANDOMIZE randseed
- mode%(7)=1:mode%(8)=2
- amtofques%=2:automark%=1:truemark%=1:fc%=0:bb%=1:cc%=1
- IF ARGCOUNT=1 THEN deffile$=ARG$(1)
- IF WBargcount=2 THEN deffile$=WBargPath$(1)+WBarg$(1)
- IF ARGCOUNT <> 1 AND WBargcount <> 2 THEN deffile$="No Test Selected"
- IF deffile$<>"No Test Selected" THEN GOSUB GetFile
- '--------------------------------------------------------------------
- starting:
- b%=bb%:c%=cc%:repeatmark%=1:RIGHT%=0
- IF reverse%=1 THEN b%=c%:c%=bb%:cc%=c%:bb%=b%:reverse%=0
- FOR count%=1 TO MAX
- gotit%(count%)=0
- NEXT count%
- '--------------------------------------------------------------------
- MenuStart:
- WINDOW ON
- WINDOW 1,"80 Questions 1.0",(xg%,yg%)-(xg%+355,yg%+193),30
- FONT "XEN",9
- fontwidth%=WINDOW(12):fontheight%=WINDOW(13)
- GADGET 1,1,deffile$,(10,5)-(330,25),2,1
- IF roro%=0 THEN GADGET 2,1,"Original",(10,30)-(160,50),1,1
- IF roro%=1 THEN GADGET 2,1,"Random ",(10,30)-(160,50),1,1
- IF srsr%=0 THEN GADGET 3,1,"Straight",(180,30)-(330,50),1,1
- IF srsr%=1 THEN GADGET 3,1,"Reversed",(180,30)-(330,50),1,1
- GADGET 4,1,"New ",(10,55)-(160,75),1,1
- GADGET 5,1,"Snapshot",(180,55)-(330,75),1,1 '..boolean
- IF samps%=1 THEN GADGET 10,1,"Responses On ",(85,80)-(255,100),1,1
- IF samps%=0 THEN GADGET 10,1,"Responses Off",(85,80)-(255,100),1,1
- GADGET 6,1,amtofques%-1,(10,105)-(330,115),4 '.."from" horizontal slider
- GADGET 7,1,amtofques%-1,(10,135)-(330,145),4 '.."to" horiz. slider
- GADGET 8,1,"Begin ",(10,155)-(160,175),1,1
- GADGET 9,1,"Help ",(180,155)-(330,175),1,1
- LOCATE (INT(100/fontheight%)),3:PRINT"From:";b%
- LOCATE (INT(134/fontheight%)),3:PRINT"To:";c%
- WHILE -1
- GADGET WAIT 0
- GOSUB handle_gad
- WEND
- handle_gad:
- gad = GADGET(1)
- IF gad=1 THEN
- deffile$=CSTR(GADGET(2))
- fc%=1
- GOSUB GetFile
- END IF
- IF gad=2 THEN
- IF roro%=0 THEN
- roro%=1:GADGET CLOSE 2:GADGET 2,1,"Random",(10,30)-(160,50),1,1
- RETURN
- END IF
- IF roro%=1 THEN
- roro%=0:GADGET CLOSE 2:GADGET 2,1,"Original",(10,30)-(160,50),1,1
- RETURN
- END IF
- END IF
- IF gad=10 THEN
- IF samps%=1 THEN
- samps%=0:GADGET CLOSE 10
- GADGET 10,1,"Responses Off",(85,80)-(255,100),1,1
- RETURN
- ELSE
- IF wrongsound%>0 AND rightsound%>0 THEN
- samps%=1:GADGET CLOSE 10
- GADGET 10,1,"Responses On ",(85,80)-(255,100),1,1
- RETURN
- END IF
- END IF
- END IF
- IF gad=3 THEN
- IF srsr%=0 THEN
- srsr%=1:GADGET CLOSE 3:GADGET 3,1,"Reversed",(180,30)-(330,50),1,1
- RETURN
- END IF
- IF srsr%=1 THEN
- srsr%=0
- GADGET CLOSE 3:GADGET 3,1,"Straight",(180,30)-(330,50),1,1
- RETURN
- END IF
- END IF
- IF gad =5 THEN GOSUB Config
- IF gad=6 THEN
- LOCATE (INT(100/fontheight%)),3:PRINT SPC(10);
- LOCATE (INT(100/fontheight%)),3
- PRINT"From:";GADGET(3)+1;" ";:b%=GADGET(3)+1
- END IF
- IF gad=7 THEN
- LOCATE (INT(134/fontheight%)),3:PRINT SPC(10);
- LOCATE (INT(134/fontheight%)),3
- PRINT"To:";GADGET(3)+1;" ";:c%=GADGET(3)+1
- END IF
- IF gad =8 AND deffile$<>"No Test Selected" THEN
- windo&=WINDOW(7):xg%=PEEKW(windo&+4):yg%=PEEKW(windo&+6):reverse%=0
- GOSUB CloseMenu
- GOTO OrderGetter
- END IF
- IF gad =9 THEN GOSUB Help
- IF gad =4 THEN GOSUB filechange
- RETURN
- '--------------------------------------------------------------------------
- OrderGetter:
- WINDOW STOP
- markadv%=1:bb%=b%:cc%=c%
- WINDOW 1,deffile$,(xm%,ym%)-(xm%+wm%,ym%+hm%),23
- FONT "XEN",9
- windo&=WINDOW(7)):wm%=PEEKW(windo&+8):centerseed%=(wm%/WINDOW(12))
- IF roro%=0 THEN
- GOTO StraightOrder
- ELSE
- GOTO RandomOrder
- END IF
- '-------------------------------------------------------------------------
- RandomOrder:
- IF b%>c% THEN bb%=b%:b%=c%:c%=bb%:cc%=c%:bb%=b%:reverse%=1
- CLS:COLOR 2,4:Center(5,"Randomizing the test"):COLOR 1,0
- a$=".":a%=7
- num% = INT(RND * (c%-b%+1)) + b%
- FOR count% = b% TO c%
- REPEAT
- same%=0
- num% = INT(RND * (c%-b%+1)) + b%
- FOR check% = b% TO count%
- IF num% = gotit%(check%) THEN same%=1
- NEXT check%
- UNTIL same%=0
- IF LEN(a$)=(centerseed%-15) THEN
- a$="."
- a%=8
- END IF
- Center(a%,a$):a$=a$+".":gotit%(count%) = num%
- NEXT count%
- GOTO Test
- '-------------------------------------------------------------------------
- StraightOrder:
- IF b%>c% THEN
- reverse%=1:bb%=b%:b%=c%:c%=bb%:cc%=c%:bb%=b%
- END IF
- IF reverse%=1 THEN
- FOR count%=b% TO c%
- gotit%(count%)=c%-count%+1
- NEXT count%
- ELSE
- FOR count%=b% TO c%
- gotit%(count%)=count%
- NEXT count%
- END IF
- GOTO Test
- '-------------------------------------------------------------------------
- Config:
- WINDOW 2,"80 Questions 1.0 (November 1994)",(xm%,ym%)-(xm%+wm%,ym%+hm%),23
- WINDOW OUTPUT 2:COLOR 1,0:CLS:a$=""
- FONT "XEN",9
- CALL Center(0, "Press [s] to save settings or [c] to cancel.")
- WHILE a$<>"s"
- a$=INKEY$
- IF a$="c" THEN
- WINDOW CLOSE 2
- RETURN
- END IF
- IF a$<>"" AND samps%=1 THEN CALL Right_Sound
- WEND
- windo&=WINDOW(7)
- xm%=PEEKW(windo&+4):ym%=PEEKW(windo&+6)
- wm%=PEEKW(windo&+8):hm%=PEEKW(windo&+10)
- CLS
- Center(5,"Saving data to your config file...")
- WINDOW OUTPUT 1:windo&=WINDOW(7):xg%=PEEKW(windo&+4):yg%=PEEKW(windo&+6)
- OPEN "O",#1,"80Questions:80Questions.cfg"
- WRITE #1,xm%,ym%,wm%,hm%,xg%,yg%,roro%,samps%,srsr%,talk%
- CLOSE #1
- PRINT:WINDOW CLOSE 2
- RETURN
- '-------------------------------------------------------------------------
- Test:
- CLS
- COLOR 2,4
- LineCenter("You have the following options selected:")
- PRINT
- COLOR 2,0
- IF talk%=1 THEN CALL LineCenter("Amiga Speech Synthesis")
- IF samps%=1 THEN CALL LineCenter("Responses")
- PRINT
- COLOR 2,4
- LineCenter("Type '-help' (including the dash) as an answer")
- LineCenter("to see how to change these options.")
- PRINT
- LineCenter("Press any key to begin test.")
- COLOR 1,0
- REPEAT SLEEP UNTIL INKEY$<>""
- timeone=TIMER
- FOR count% = b% TO c%
- 5 CLS
- COLOR 3,0
- PRINT"Question";(count%-b%+1);"out of";(c%-b%+1);".",
- IF automark%=0 THEN
- PRINT"Automarking is off."
- ELSE
- PRINT"Automarking is on."
- END IF
- IF (count%-b%)>0 THEN PRINT"Current percentage: ",INT(RIGHT%/(count%-b%)*100);"%",
- PRINT"(";RIGHT%;"for";(count%-b%);")"
- COLOR 1,0
- GOSUB Setup
- COLOR 2,0
- INPUT yourans$
- IF yourans$ = "-back" THEN
- CALL Lookback(count%,b%)
- GOTO 5
- END IF
- IF yourans$ = "-quit" THEN GOTO Stopping
- IF yourans$ = "-responses off" THEN
- samps%=0
- GOTO 5
- END IF
- IF yourans$ = "-talk off" THEN
- talk%=0
- GOTO 5
- END IF
- IF yourans$ = "-help" THEN
- GOSUB Help
- GOTO 5
- END IF
- IF yourans$ = "-talk on" THEN
- talk%=1
- GOTO 5
- END IF
- IF yourans$ = "-responses on" THEN
- IF (wrongsound%=0 OR rightsound%=0) THEN GOTO 5
- samps%=1
- GOTO 5
- END IF
- num%=gotit%(count%)
- IF answer$(num%) = yourans$ AND srsr%=0 THEN
- GOSUB RightRoutine
- GOTO 20
- END IF
- IF question$(num%)=yourans$ AND srsr%=1 THEN
- GOSUB RightRoutine
- GOTO 20
- END IF
- COLOR 1,0
- PRINT
- PRINT "Wrong, press:"
- PRINT " a) to try again."
- PRINT " m) to take your error like a man."
- 10 REPEAT
- SLEEP
- a$ = INKEY$
- UNTIL a$<>""
-
- IF a$ = "" THEN 10
- IF a$ = "a" THEN 5
- IF a$ = "m" THEN
- GOSUB WrongRoutine
- GOTO 20
- END IF
- IF a$<>"" THEN BEEP
- GOTO 10
- 20 NEXT count%
- GOTO Stopping
- '-------------------------------------------------------------------------
- Stopping:
- TIME = TIMER - timeone
- CALL TotalTime(TIME)
- CLS
- COLOR 1,0
- LOCATE 2, 1
- PRINT "Total time: ";hours%;"hours";minutes%;"minutes and";INT(seconds%);"seconds."
- LOCATE 4, 1
- PRINT "You got"; RIGHT%; "correct out of"; (count% - b%); "."
- IF (count% - b%) <= 0 THEN
- Center(6, "I hope you can do more questions for the test!")
- GOTO StartOver
- END IF
- PRINT "This is"; (RIGHT% / (count% - b%) * 100); "percent."
- IF markadv%>1 THEN
- PRINT "You also have";(markadv%-1);"incorrect answer(s) marked for repeating."
- ELSE
- repeatmark%=1
- END IF
- PRINT
- GOTO StartOver
- '-------------------------------------------------------------------------
- StartOver:
- COLOR 2,4
- LineCenter("[m] Main menu. ")
- IF repeatmark%=1 THEN
- CALL LineCenter("[r] Repeat last test. ")
- ELSE
- CALL LineCenter("[w] Repeat only the marked questions.")
- END IF
- LineCenter("[e] Repeat entire test. ")
- LineCenter("[q] Quit. ")
- COLOR 1,0
- 40 REPEAT
- SLEEP
- a$ = INKEY$
- UNTIL a$<>""
- IF a$="w" AND markadv%>1 THEN
- b%=1:c%=markadv%-1:markadv%=1:RIGHT%=0
- automark%=0
- GOTO Test
- END IF
- IF a$="e" THEN
- repeatmark%=0
- a$="r"
- END IF
- IF a$ = "m" THEN
- windo&=WINDOW(7)
- xm%=PEEKW(windo&+4):ym%=PEEKW(windo&+6)
- wm%=PEEKW(windo&+8):hm%=PEEKW(windo&+10)
- automark%=truemark%:amtofques%=oldamt%
- WINDOW CLOSE 1
- GOTO starting
- END IF
- IF a$ = "q" THEN
- WINDOW CLOSE 1
- SYSTEM "assign 80Questions:"
- STOP
- END IF
- IF a$ = "r" THEN
- RIGHT%=0
- IF repeatmark%=1 THEN GOTO Test
- b%=bb%:c%=cc%:automark%=truemark%
- FOR count%=1 TO MAX
- gotit%(count%)=0
- NEXT count%
- GOTO OrderGetter
- END IF
- IF a$<>"" THEN BEEP
- GOTO 40
- '-------------------------------------------------------------------------
- Setup:
- LOCATE 4, 1
- IF srsr%=0 THEN
- Printques$ = question$(gotit%(count%))
- ELSE
- Printques$ = answer$(gotit%(count%))
- END IF
- IF talk%=1 THEN SAY TRANSLATE$(Printques$),mode%
- WordWrap(PRINTques$)
- RETURN
- '-------------------------------------------------------------------------
- RightRoutine:
- IF samps%=1 THEN CALL Right_Sound
- RIGHT% = RIGHT% + 1
- RETURN
- '-------------------------------------------------------------------------
- WrongRoutine:
- CLS
- Center(2,"Wrong! The answer was supposed to be:")
- COLOR 2,3
- IF srsr%=0 THEN
- text$=answer$(num%)
- WordWrap(text$)
- ELSE
- text$=question$(num%)
- WordWrap(text$)
- END IF
- COLOR 1,0
- PRINT
- LineCenter("You had put:")
- COLOR 1,2
- WordWrap(yourans$)
- COLOR 1,0
- PRINT
- IF automark%=0 THEN CALL LineCenter("m) Mark for repeating later. ")
- LineCenter("t) Make it correct since it was an ")
- LineCenter(" insignificant typo. ")
- LineCenter("<or>")
- LineCenter("Press any key to continue.")
- REPEAT
- SLEEP
- a$=INKEY$
- UNTIL a$<>""
- IF a$ = "t" THEN GOSUB RightRoutine
- IF a$ = "m" AND automark%=0 THEN
- gotit%(markadv%)=gotit%(count%)
- markadv%=markadv%+1
- repeatmark%=0
- CALL LineCenter("(Marked!)")
- END IF
- IF automark%=1 AND a$<>"t" THEN
- gotit%(markadv%)=gotit%(count%)
- repeatmark%=0
- markadv%=markadv%+1
- END IF
- IF samps%=1 AND a$<>"t" AND a$<>"m" THEN CALL Wrong_Sound
- RETURN
- '-------------------------------------------------------------------------
- FileChange:
- fc%=1
- path$=FILEBOX$("New Test")
- IF path$="" THEN GOTO outpath
- deffile$=path$
- GetFile:
- cdir$=deffile$:pe%=0
- REPEAT
- IF MID$(deffile$,LEN(deffile$)-pe%,1)="/" OR MID$(deffile$,LEN(deffile$)-pe%,1)=":" THEN cdir$=LEFT$(deffile$,(LEN(deffile$)-pe%))
- ++pe%
- UNTIL (pe%=LEN(deffile$)+1) OR cdir$<>deffile$
- IF cdir$<>deffile$ THEN CHDIR cdir$
- amtofques% = 1
- OPEN "I",1,deffile$
- IF EOF(1)<>0 THEN
- deffile$="No Test Selected"
- amtofques%=2
- CLOSE 1
- RETURN
- END IF
- b%=1:c%=1:bb%=1:cc%=1:b$=".":a%=5
- WINDOW 2,"80 Questions",(xg%+60,yg%)-(xg%+296,yg%+100),22
- WINDOW OUTPUT 2
- FONT "XEN",9
- center (1,"Programming by")
- center (2,"Sean J. Miller")
- center(4,"Getting the test...")
- WHILE EOF(1)=0 AND (amtofques%<=MAX)
- a$="":q$=""
- WHILE q$="" AND EOF(1)=0
- LINE INPUT #1, q$
- WEND
- WHILE a$="" AND EOF(1)=0
- LINE INPUT #1, a$
- WEND
- b$=b$+"."
- IF LEN(b$)>((220/WINDOW(12))-5) THEN
- b$=".":a%=a%+1
- END IF
- center(a%,b$)
- question$(amtofques%) = LEFT$ (q$,179)
- answer$(amtofques%) = LEFT$(a$,179)
- if q$<> "" THEN amtofques% = amtofques% + 1
- WEND
- GotData:
- amtofques% = amtofques% - 1:oldamt%=amtofques%
- IF fc%=1 THEN
- fc%=0
- WINDOW OUTPUT 1
- GADGET CLOSE 1:GADGET CLOSE 6:GADGET CLOSE 7
- GADGET 1,1,deffile$,(10,5)-(330,25),2,1
- GADGET 6,1,amtofques%-1,(10,105)-(330,115),4
- GADGET 7,1,amtofques%-1,(10,135)-(330,145),4
- LOCATE (INT(100/fontheight%)),3:PRINT SPC(10);
- LOCATE (INT(100/fontheight%)),3:PRINT"From:";b%;" ";
- LOCATE (INT(134/fontheight%)),3:PRINT SPC(10);
- LOCATE (INT(134/fontheight%)),3:PRINT"To:";c%;" ";
- END IF
- WINDOW CLOSE 2
- WINDOW OUTPUT 1
- outpath:
- CLOSE 1
- RETURN
- CloseMenu:
- FOR count%=1 TO 10
- GADGET CLOSE count%
- NEXT count%
- WINDOW CLOSE 1
- RETURN
- '-------------------------------------------------------------------------
- Help:
- WINDOW STOP
- WINDOW 2,"80 Questions 1.0 (November 1994) by Sean J. Miller",(xm%,ym%)-(xm%+wm%,ym%+hm%),23
- FONT "XEN",9
- COLOR 2,0
- CLS
- Center(2,"HELP")
- Center(4,"--To make a test, just go to any text editor or wordprocessor ")
- Center(5," and type in your questions and answers consecutively in ")
- Center(6," the order you choose. Use a hard return at the end of each ")
- Center(7," question and answer and do not allow word wrapping. ")
- Center(8," Also, be sure to export it as an ASCII file which is usually")
- Center(9," a standard option on most text editors and word processors. ")
- Center(11,"--Questions and answers must not be greater than 180 letters. ")
- REPEAT SLEEP UNTIL INKEY$<>""
- CLS
- Center(2, "--Only 80 questions are allowed due to memory limits. ")
- Center(4, "--To start a test click once on the test's icon, hold down ")
- Center(5, " shift, and then double click on the 80Questions' icon. ")
- Center(7, "--To take a different test without ending the program, ")
- Center(8, " select the 'NEW' gadget and find the test's path. ")
- Center(10, "--Automarking automatically sets aside missed questions so ")
- Center(11, " you can repeat them later. It is turned off when repeat-")
- Center(12, " ing the missed questions so you can mark new errors. ")
- REPEAT SLEEP UNTIL INKEY$<>""
- CLS
- Center(2, "The following actions can be done during the test by typing ")
- Center(3, "in the appropriate keyword: ")
- Center(4, " Keyword Action ")
- Center(5, " ------- ------ ")
- Center(6, " -quit Ends test at the previous ")
- Center(7, " question. ")
- Center(9, " -responses on *Turns the sampled responses on. ")
- Center(11, " -responses off Turns the sampled responses off. ")
- Center(13, " * You must have at least ONE path of a sample in the files")
- center(14, " <rightiffs> and <wrongiffs>. See docs for more info. ")
- REPEAT SLEEP UNTIL INKEY$<>""
- CLS
- Center(2, " Keyword Action ")
- Center(3, " ------- ------ ")
- Center(4, " -talk on Turns the Amiga speech on. ")
- Center(5, " -talk off Turns the Amiga speech off. ")
- Center(7, " -back Allows one to view previous ")
- Center(8, " questions. ")
- REPEAT SLEEP UNTIL INKEY$<>""
- WINDOW CLOSE 2
- WINDOW ON
- RETURN
-
- SUB Center(row, Text$)
- fontwidth%=WINDOW(12):fontheight%=WINDOW(13)
- windo&=WINDOW(7):wm%=PEEKW(windo&+8)
- IF row=0 THEN
- hm%=PEEKW(windo&+10)
- row=INT((hm%/fontheight%)/2)-1
- END IF
- Col% = INT((wm%/fontwidth%) / 2)
- LOCATE row, INT(Col% - (LEN(Text$) / 2))
- PRINT Text$
- END SUB
- SUB LineCenter(Text$)
- fontwidth%=WINDOW(12):fontheight%=WINDOW(13):windo&=WINDOW(7)
- wm%=PEEKW(windo&+8):Col% = INT((wm%/fontwidth%) / 2)
- PRINT TAB(INT(Col% - (LEN(Text$) / 2)));
- PRINT Text$
- END SUB
- SUB WordWrap(Text$)
- fontwidth%=WINDOW(12):fontheight%=WINDOW(13):windo&=WINDOW(7)
- wm%=PEEKW(windo&+8):centerseed%=(wm%/fontwidth%)
- WHILE LEN(text$) >= centerseed%-5
- FOR spaced%=(centerseed%-5) TO 1 STEP -1
- IF MID$(text$,spaced%,1)=" " THEN EXIT FOR
- NEXT spaced%
- PRINT LEFT$(text$, spaced%)
- text$ = RIGHT$(text$, (LEN(text$) - spaced%))
- WEND
- PRINT text$
- END SUB
- SUB TotalTime(TIME)
- SHARED hours%,minutes%,seconds%
- hours%=0:minutes%=0:seconds%=0
- IF (TIME/3600)>1 THEN
- hours%=INT(TIME/3600):TIME= TIME MOD 3600
- END IF
- IF (TIME/60)>1 THEN
- minutes%=INT(TIME/60):seconds%= TIME MOD 60
- END IF
- IF TIME<60 THEN seconds%=TIME
- END SUB
- SUB Wrong_Sound
- SHARED wrongsound%, WrongIFFs$
- WHILE SAY(0) : SLEEP : WEND
- rand%=INT(RND*wrongsound%)+1
- song$=WrongIFFs$(rand%)
- CALL play_sound(song$)
- END SUB
- SUB Right_Sound
- SHARED rightsound%, RightIFFs$
- WHILE SAY(0) : SLEEP : WEND
- rand%=INT(RND*rightsound%)+1
- song$=RightIFFs$(rand%)
- CALL play_sound(song$)
- END SUB
-
- SUB Lookback(most%,b%)
- SHARED question$, answer$, gotit%
- count%=most%
- StartBack:
- CLS
- COLOR 2,3
- PRINT"The current question and answer is:"
- COLOR 1,0
- WordWrap(question$(gotit%(most%)))
- PRINT
- WordWrap(answer$(gotit%(most%)))
- PRINT
- COLOR 2,3
- PRINT"Question";count%-b%+1;"and its answer is:"
- COLOR 1,0
- WordWrap(question$(gotit%(count%)))
- PRINT
- WordWrap(answer$(gotit%(count%)))
- PRINT
- COLOR 2,3
- LineCenter("Press <+> to advance, <-> to go back,")
- LineCenter("or <s> to stop.")
- COLOR 1,0
- LoopBack:
- a$=""
- WHILE a$=""
- a$=INKEY$
- WEND
- IF a$="+" AND count%<most% THEN
- ++count%
- GOTO StartBack
- END IF
- IF a$="-" AND (count%-b%)>0 THEN
- --count%
- GOTO StartBack
- END IF
- IF a$="s" THEN GOTO EndBack
- GOTO LoopBack
- EndBack:
- END SUB
- SUB parse_sample(f$)
- SHARED offset&,samples_per_second&
- CONST default_rate=10000&
- OPEN "I",1,f$
- dummy$=INPUT$(8,#1)
- x$=INPUT$(4,#1)
- IF x$="8SVX" THEN
- sample_format$="IFF 8SVX"
- dummy$=INPUT$(8,#1)
- dummy$=INPUT$(12,#1)
- '..get sampling rate bytes
- hi%=ASC(INPUT$(1,#1)) '..high BYTE
- lo%=ASC(INPUT$(1,#1)) '..low BYTE
- samples_per_second&=hi%*256 + lo%
- dummy$=INPUT$(6,#1)
- offset&=40 '..bytes up TO this POINT
- REPEAT
- REPEAT
- x$=INPUT$(1,#1)
- offset&=offset&+1
- UNTIL x$="B" AND NOT EOF(1)
- IF NOT EOF(1) THEN
- body$=INPUT$(3,#1)
- offset&=offset&+3
- END IF
- UNTIL body$="ODY" AND NOT EOF(1)
- IF NOT EOF(1) THEN
- x$=INPUT$(4,#1) '..skip ####
- offset&=offset&+4
- ELSE
- GOTO parseout
- END IF
- CLOSE 1
- ELSE
- CLOSE 1
- sample_format$="unknown"
- offset&=0
- samples_per_second&=default_rate
- END IF
- parseout:
- END SUB
-
- SUB play_sound(f$)
- SHARED offset&,samples_per_second&
- CONST maxsample=131070
- CONST channel=1
- CONST CHIP=0, MAXCHIP=2
- DIM wave_ptr&(100)
- OPEN "I",1,f$
- sample_size&=LOF(1)
- CLOSE 1
- IF sample_size&=0 THEN GOTO playout
- parse_sample(f$)
- buffer&=ALLOC(sample_size&,CHIP) '...sample_size& bytes of CHIP RAM
- IF buffer& = NULL THEN
- avail&=FRE(MAXCHIP) '..max. contiguous CHIP RAM
- PRINT "Largest contiguous CHIP RAM is";avail&;"bytes."
- GOTO playout
- END IF
- OPEN "I",1,f$
- fh&=HANDLE(1)
- IF fh&=0 THEN
- PRINT "Can't open ";f$;"."
- GOTO playout
- END IF
- bytes&=xRead(fh&,buffer&,sample_size&)
- CLOSE 1
- per& = 3579546 \ samples_per_second&
- sz&=sample_size&-offset&
- IF sz& <= maxsample THEN
- WAVE channel,buffer&+offset&,sz&
- dur&=.279365*per&*bytes&/1e6*18.2
- SOUND per&,dur&,,channel
- ELSE
- segments&=sz&\maxsample
- buf&=buffer&+offset&
- FOR i&=0 TO segments&
- wave_ptr&(i&)=buf&+maxsample*i&
- NEXT
- FOR i&=0 TO segments&
- IF sz& >= maxsample THEN
- WAVE channel,wave_ptr&(i&),maxsample
- bytes&=maxsample
- ELSE
- WAVE channel,wave_ptr&(i&),sz&
- bytes&=sz&
- END IF
- dur&=.279365*per&*bytes&/1e6*18.2
- SOUND per&,dur&,,channel
- sz&=sz&-maxsample
- NEXT
- END IF
- playout:
- END SUB
-
- ending:
- GOSUB CloseMenu
- SYSTEM "assign 80Questions:"
- STOP
-
-